package cn.hh.wechatkit.util;

import com.blade.kit.EncrypKit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

/**
 * Created this one by HMH on 2017/3/29.
 * 获取JsSdk签名
 */

public class WxSignUtil {
final static Logger logger = LoggerFactory.getLogger(WxSignUtil.class);

    public static String signaure(String connectStr,String... param) {
        if (param.length == 0) {
            return "";
        }
        ArrayList<String> list = new ArrayList<>();
        list.addAll(Arrays.asList(param));
        Collections.sort(list);
        StringBuilder strSum = new StringBuilder();
        strSum.append(list.get(0));
        for(int i=1;i<list.size();i++) {
            strSum.append(connectStr);
            strSum.append(list.get(i));
        }
        logger.info("签名加密序列:"+strSum);
        return EncrypKit.encryptSHA1ToString(strSum.toString());
    }
}
